import { GSprite } from "../../../../../com/mui/controls/GSprite";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ObjCreate } from "../../common/ObjCreate";
import { StaticResUrl } from "../../../resource/StaticResUrl";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FontUtil } from "../../../../common/font/FontUtil";
import { Language } from "../../../../../extend/language/Language";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { EliteTowerFloorData } from "./EliteTowerFloorData";
import { Cache } from "../../../cache/Cache";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { SecTimerView } from "../../common/SecTimerView";
type int = number;
//class EliteTiaoZhanSp
    
    export  class EliteTiaoZhanSp extends GSprite
    {
        constructor()
        {
            super();
            this.addChild(new GImageBitmap(ImagesConst.GuildEliteTiaoZhan, 15, 30));
            ObjCreate.createLoadedBitmap(StaticResUrl.littleBoxxx, 230, -8, this);
            var loc1=GlobalStyle.setTextFormatLeading(GlobalStyle.textFormat6, 5);
            loc1.font = FontUtil.stXingkaiName;
            loc1.size = 18;
            loc1.color = 16776960;
            this._floorBm = ObjCreate.createBitmap(null, 10, 7, this);
            this._floorText = ObjCreate.createGTextField(Language.getString(60602), 8, 5, 270, 30, this, loc1, true, false);
            loc1.color = GlobalStyle.color1Uint;
            loc1.size = 12;
            loc1.font = FontUtil.defaultName;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            loc1.bold = true;
            this._wofangrenshu = ObjCreate.createGTextField(Language.getStringByParam(60603, 0, 0), 0, 117, 106, 60, this, loc1, true, false);
            loc1.color = GlobalStyle.color5Uint;
            loc1.bold = false;
            this._leftTime = ObjCreate.createSecTimeView(Language.getString(60604), 90, 117, 103, 60, this, loc1);
            this._leftTime.filters = [FilterConst.glowFilter];
            loc1.color = GlobalStyle.color1Uint;
            loc1.bold = true;
            this._witchFloor = ObjCreate.createGTextField(Language.getString(60611), 177, 117, 106, 60, this, loc1, true, false);
            return;
        }

        public onResLoaded(): void
        {
            this.updatefloortxt();
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            this._leftTime.setParse(Language.getString(60604));
            this._leftTime.setLeftTime(arg1);
            return;
        }

        public updatePreLeftTime(arg1: int): void
        {
            this._leftTime.setParse(Language.getString(60637));
            this._leftTime.setLeftTime(arg1);
            return;
        }

        public updatePlayerNum(arg1: int, arg2: int): void
        {
            this._wofangrenshu.htmlText = Language.getStringByParam(60603, arg1, arg2);
            return;
        }

        public updateData(arg1: EliteTowerFloorData): void
        {
            var loc1=0;
            if (arg1 == null) 
            {
                loc1 = Cache.instance.guildElite.maxFloor;
                arg1 = Cache.instance.guildElite.getDataByFloor(loc1);
                if (arg1) 
                {
                    this._maxFloor = true;
                    this._floor = loc1;
                    this._witchFloor.htmlText = Language.getStringByParam(60611, arg1.floor, arg1.copyName);
                }
            }
            else 
            {
                this._maxFloor = false;
                this._floor = arg1.floor;
                this._witchFloor.htmlText = Language.getStringByParam(60611, arg1.floor, arg1.copyName);
            }
            if (arg1) 
            {
                this.updatePlayerNum(Cache.instance.guildElite.getPlayerNumByCopycode(arg1.copyCode), arg1.maxPlayerNum);
            }
            this.updatefloortxt();
            return;
        }

        /* internal  */updatefloortxt(): void
        {
            if (this._maxFloor) 
            {
                if (GlobalClass.hasRes(ImagesConst.guildEliteText_dqktzzgc)) 
                {
                    this._floorBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.guildEliteText_dqktzzgc);
                }
                this._floorText.x = this._floorBm.x + this._floorBm.width;
                this._floorText.htmlText = Language.getStringByParam(60608, this._floor);
            }
            else 
            {
                if (GlobalClass.hasRes(ImagesConst.guildEliteText_dqcc)) 
                {
                    this._floorBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.guildEliteText_dqcc);
                }
                this._floorText.x = this._floorBm.x + this._floorBm.width;
                this._floorText.htmlText = Language.getStringByParam(60608, this._floor);
            }
            return;
        }

        /* internal */ /* var */_floorBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_floorText: GTextFiled;

        /* internal */ /* var */_wofangrenshu: GTextFiled;

        /* internal */ /* var */_leftTime: SecTimerView;

        /* internal */ /* var */_witchFloor: GTextFiled;

        /* internal */ /* var */_maxFloor: Boolean;

        /* internal */ /* var */_floor: int;
    }
